<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        body{
            background-color: #000000;
        }
        .box{
            position: relative;
            margin: 50px auto;
            width: 1000px;
            height: 42px;
            background: #fff url('./rss.png') no-repeat right;
            
        }
        .box>ul{
            position: absolute;
            top: 0;
            left: 0;
            list-style: none;
            z-index: 10;
        }
        .box>ul>li{  
            float: left;
            width: 83px;
            height: 42px;
            text-align: center;
            line-height: 42px;
            /* 鼠标变成小手 */
            cursor: pointer;
        }
        .box>span{
            position: absolute;
            top: 0;
            left: 0;
            width: 83px;
            height: 42px;
            background: url('./cloud.gif') no-repeat center;
        }
    </style>
</head>
<body>
    <div class="box">
        <ul>
            <li>新闻首页</li>
            <li>新闻首页</li>
            <li>新闻首页</li>
            <li>新闻首页</li>
            <li>新闻首页</li>
            <li>新闻首页</li>
            <li>新闻首页</li>
            <li>新闻首页</li>
        </ul>
        <span id="cloud"></span>
    </div>
</body>
<script>
    var lis = document.querySelectorAll('li');
    var sps = document.querySelector('#cloud');
    var targer = 0;//目标值
    var lerder = 0;//步长
    var current = 0 //当前点击的位置
    lis.forEach((item)=>{
        item.onmouseover = function(){
            targer = this.offsetLeft
        }
        item.onclick = function(){
            current = targer
        }
        item.onmouseout = function(){
            // console.log('nihao');
            targer = current
        }
    })
    function fn(){
        lerder = lerder + (targer - lerder)/10
        sps.style.left = lerder + 'px'
    }
    setInterval(fn, 30);
</script>
</html>